package com.example.controller;

import com.example.service.Producer;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Destination;

@RestController
public class HelloController {

    @Autowired
    private Producer producer;

    @GetMapping("/")
    public String home() {
        return "Hello ,spring boot!";
    }

    @PostMapping("/message-send")
    public String messageSend(@RequestParam("message") String message) {
        for (int i = 0; i < 10; i++) {
            producer.sendMessage(message);
        }
        return "ok";
    }
}
